<script type="text/javascript">
 
</script>

<div class="container_topmenu">
	<div class="grid_12">
		<div class="grid_3">
			<h5>User Management</h5>
		</div>
		<span class="topmenu">
		 <?php ///if (in_array('users_groups', $this->permission->permissions)): ?>
		<a href="<?php echo site_url('/ssm/usergroup'); ?>" class="button blue">User Group</a>
	<?php //endif; ?>	
		</span>	
		<span class="topmenu">
			<a href="<?php echo site_url('/ssm/add_user'); ?>" class="button" id="btnAdd">Add User</a>
		</span>		
	</div>
</div>

<div class="container_12">
 
	<div class="grid_12">
		<table class="default" width="100%">
			<tr>
				<th><?php echo order_link('/ssm/users','username','Username'); ?></th>
				<th><?php echo order_link('/ssm/users','lastname','Name'); ?></th>
				<th><?php echo order_link('/ssm/users','email','Email'); ?></th>
				<th><?php echo order_link('/ssm/users','groupid','Group'); ?></th>
				<th><?php echo order_link('/ssm/users','active','Status'); ?></th>
				<th><?php echo order_link('/ssm/users','datecreated','Date Created'); ?></th>
				<th class="tiny">&nbsp;</th>
				<th class="tiny">&nbsp;</th>		
			</tr>
			

<?php foreach ($users as $user): ?>
<?php 
	$class = '';
	if ($user['groupID'] == $this->site->config['groupID'] || $user['groupID'] < 0) $class = 'class="blue"';
	elseif (@in_array($user['groupID'], $adminGroups)) $class = 'class="orange"';

	$username = ($user['username']) ? $user['username'] : '(not set)';
	$userlink = (in_array('users_edit', $this->permission->permissions)) ? anchor('/ssm/edit_user/'.$user['userID'], $username) : $username;
?>
	<tr <?php echo $class; ?>>
		<td><?php echo $userlink; ?></td>
		<td><?php echo trim($user['firstName'].' '.$user['lastName']); ?></td>
		<td><?php echo $user['email']; ?></td>
		<td>
			<?php
				if ($user['groupID'] == $this->site->config['groupID'] || $user['groupID'] < 0) echo 'Administrator';
				elseif (@in_array($user['groupID'], $adminGroups)) echo $userGroups[$user['groupID']];
				elseif (@in_array($user['groupID'], $normalGroups)) echo $userGroups[$user['groupID']];
			?>
		</td>
		<td><?php echo $user['active']=1?'Active':'Not Active'; ?></td>
		<td><?php echo dateFmt($user['dateCreated'], '', '', TRUE); ?></td>		
		<td class="tiny">
			<?php // if (in_array('users_edit', $this->permission->permissions)): ?>
				<?php echo anchor('/ssm/edit_user/'.$user['userID'], 'Edit'); ?>
			<?php // endif; ?>
		</td>
		<td class="tiny">
			<?php //if (in_array('users_delete', $this->permission->permissions)): ?>
				<?php echo anchor('/ssm/delete/'.$user['userID'], 'Delete', 'onclick="return confirm(\'Are you sure you want to delete this?\')"'); ?>
			<?php //endif; ?>

		</td>
	</tr>
<?php endforeach; ?>
</table>
	</div>


	<div class="clear"></div>
	<div style='height: 30px'>
		<p style="text-align: right;">
			<a href="#" class="button grey" id="totop">Back to top</a>
		</p>
	</div>
 